# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Jingbei Li <i@jingbei.li>
# Contributor: Intel Corporation <http://www.intel.com/software/products/support>

_pkgname='intel-oneapi'
pkgname="${_pkgname}-common"
pkgver=2023.2.0
_debpkgrel=49462
pkgrel=1
pkgdesc="Intel's oneAPI common variables and licensing"
arch=('any')
url='https://software.intel.com/content/www/us/en/develop/tools/oneapi.html'
license=("custom")
source=("https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
        "https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb")
b2sums=('1f259a77d727f18387966a261c5a13f83f4cb7e732c6787ea615b4aa57bb9807c70040f11606e515d437078e96b73ce745b2c81e5690a972351b5afac7aa66d0'
        '2a2932e03a48ea019d80a5b7b787af353aed9e8415fef77ea16563fc28705438c65b5bc97fb6e7bded376e0b174a2df244fa2d4e75a2bee32041cb0e0b8b7af8')
depends=('sh')
optdepends=("procps-ng: Sourcing /opt/intel/oneapi/setvars.sh")
noextract=(
    "${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
    "${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb"
)
conflicts=('intel-oneapi-basekit')

build() {
    mkdir vars licensing package

}

package() {
    cd "${srcdir}"
    ar x "${srcdir}/${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    ar x "${srcdir}/${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    ln -sfT "${pkgver}" "${pkgdir}"/opt/intel/oneapi/licensing/latest
    install -d "${pkgdir}"/usr/share/licenses/"${pkgname}"
    ln -s /opt/intel/oneapi/licensing/latest "${pkgdir}"/usr/share/licenses/"${pkgname}"/latest
    ln -s "${pkgname}" "${pkgdir}"/usr/share/licenses/"${_pkgname}"
    ls -lah "${pkgdir}"/usr/share/licenses
}
